/**
 * Classname: problem3_Garg
 * Version: 1.0
 * Date: 03/13/2009
 * Author: Dilip Garg
 */
 
import java.util.Scanner;

/**
 * This class implements the well-parenthesized expression 
 * checking using divide and conquer algorithm. The running 
 * time is O(n log n).
 */

public class problem3_Garg
{
	String str;
	
	// Default Constructor
	public problem3_Garg()
	{
		str = "";
	}
	
	// Main method
	public static void main(String[] args)
	{
		// User input
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		
		// If checkParentheses returns "Well-parenthesized" return true
		if (checkParentheses(str).equalsIgnoreCase("Well-parenthesized"))
			System.out.println("YES"); // Output "YES"
		else
			System.out.println("NO"); // Output "NO", otherwise
	}
	
	/**
	 * This method checks the given expression for well-parenthesize'ness 
	 * @arg1 input expression
	 * @return "Well-parenthesized", if the string is well-parenthesized
	 *         "Not Well-parenthesized", otherwise
	 */
	public static String checkParentheses(String input)
	{
		// If the string is empty
		if (input.length() == 0)
			return "Well-parenthesized";
		
		// If the string is odd-length'd
		if (input.length() % 2 != 0)
			return "Not Well-parenthesized";
		
		/*
		 * If the starting and ending characters match i.e.
		 * either starting "(" and ending ")"
		 * or starting "{" and "}"  
		 */
		if ((input.charAt(0) == '(' & input.charAt(input.length()-1) == ')') |   
				 (input.charAt(0) == '{' & input.charAt(input.length()-1) == '}'))
		{
			/*
			 * Recurse the substring of input and check if the returned value is 
			 * "Well-parenthesized". If yes, then return "Well-parenthesized" 
			 */
			if (checkParentheses(input.substring(1, input.length()-1))
					.equalsIgnoreCase("Well-parenthesized"))
				return "Well-parenthesized";
		}
		
		/*
		 * For all substrings of input starting from the first character up to 
		 * half of the input string, and then continuing the for loop for 
		 * increasing values of i
		 */
		for (int i =1; i <= input.length()/2-1; i++)
		{
			// Keep recursing on first half of the substring and store the result into ok1
			String ok1 = checkParentheses(input.substring(0, 2*i));

			// Keep recursing on second half of the substring and store the result into ok2
			String ok2 = checkParentheses(input.substring(2*i, input.length()));
			
			// If both of the ok1 and ok2 are "Well-parenthesized" 
			if (ok1.equalsIgnoreCase("Well-parenthesized") 
	    			& ok2.equalsIgnoreCase("Well-parenthesized"))
				return "Well-parenthesized";
		}
		
		/*
		 *  If the function has not returned any value, then return 
		 *  "Well-parenthesized"
		 */
		return "Not Well-parenthesized";	
	}	
}